//
//  LTAboutUsViewController.m
//  Learn
//
//  Created by zyl_macbookpro on 2024/4/1.
//  Copyright © 2024 迟建国. All rights reserved.
//

#import "LTAboutUsViewController.h"
#import "LTMineAPIManager.h"
@interface LTAboutUsViewController ()<UITableViewDelegate,UITableViewDataSource,YYTextViewDelegate>

@property(nonatomic ,strong)UITableView *tableView;

@property(nonatomic ,strong)UIView *tableHeaderView;

@property(nonatomic ,strong)UIView *tableFootorView;

@property(nonatomic ,strong)UILabel *numLabel;

@property(nonatomic ,strong)NSArray *titleArray;


@end

@implementation LTAboutUsViewController
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"关于我们";
    // Do any additional setup after loading the view.
    [self setBackButtonIsHidden:NO];
    [self.view addSubview:self.tableView];
    [self.tableView reloadData];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        self.tableView.height = self.tableView.contentSize.height + 1;
    });
    
}


#pragma mark -UITableViewDelegate,UITableViewDelegate
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = nil;
    
    if (!cell)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@""];
        cell.selectionStyle =UITableViewCellSelectionStyleNone;
    }
    [cell removeAllSubviews];
    UIImageView *img =  [[UIImageView alloc] initWithImage:IMAGENAMED(@"ic_right_arrow_gray")];
    [img setFrame:CGRectMake(LTScreenWidth - 28 - 32, (55 - 12)/2.0, 12, 12)];
    UILabel *detailTextLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, LTScreenWidth - 50, 55)];
    detailTextLabel.textAlignment = NSTextAlignmentLeft;
    detailTextLabel.textColor = LTTextBlack;
    detailTextLabel.font = MFontWithSize(15);
    NSDictionary *dic = self.titleArray[indexPath.row];
    detailTextLabel.text = dic.allValues.firstObject;
    [cell addSubview:detailTextLabel];
    [cell addSubview:img];
    return cell;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.titleArray.count;
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return 55;
    
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    UIViewController *vc = [[UIViewController alloc] initWithClassName:@"LTProtocolShowViewController"];
    vc.paraObject =  self.titleArray[indexPath.row];
    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark -getters and setters
-(UITableView *)tableView{
    if (!_tableView){
        _tableView =[[UITableView alloc] initWithFrame:CGRectMake(16, LTTopBarHeight + 16, LTScreenWidth - 32, LTScreenHeight - LTTopBarHeight) style:UITableViewStylePlain];
        [_tableView setDelegate:self];
        [_tableView setDataSource:self];
        _tableView.bounces = NO;
        [_tableView setBackgroundColor:LTWhiteColor];
        [_tableView setSeparatorColor:LTSeparatorColor];
        [_tableView setSeparatorInset:UIEdgeInsetsMake(0, 20, 0, 20)];
        _tableView.layer.cornerRadius = 12;
        _tableView.layer.shadowColor = [UIColor colorWithRed:0/255.0 green:50/255.0 blue:83/255.0 alpha:0.0500].CGColor;
        _tableView.layer.shadowOffset = CGSizeMake(0,2);
        _tableView.layer.shadowOpacity = 1;
        _tableView.layer.shadowRadius = 12;
        [_tableView setTableHeaderView:self.tableHeaderView];
    }
    
    return _tableView;
}


-(UIView *)tableHeaderView
{
    if (!_tableHeaderView)
    {
        _tableHeaderView =[[UIView alloc] initWithFrame:CGRectMake(0, 0, LTScreenWidth, 250)];
        
        _tableHeaderView.backgroundColor = LTClearColor;
       
        UIImageView *headerImageView = [[UIImageView alloc] initWithFrame:CGRectMake((LTScreenWidth - 32 - 64)/2.0, 32, 64, 64)];
        headerImageView.image = IMAGENAMED(@"ic_mine_about_logo");
        [_tableHeaderView addSubview:headerImageView];
    
        UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(32, headerImageView.bottom + 12, LTScreenWidth - 64, 30)];
        titleLabel.font = MFontWithSize(16);
        titleLabel.text = @"学而时习 (教师端)";
        [titleLabel setTextAlignment:NSTextAlignmentCenter];
        titleLabel.textColor = LTTextBlack;
        [_tableHeaderView addSubview:titleLabel];
        _tableHeaderView.height = titleLabel.bottom + 40;
        
    }
    
    return _tableHeaderView;
    
}
- (NSArray *)titleArray
{
    if (!_titleArray) {
        _titleArray = @[@{@"teacher_use_agreement":@"教师使用协议"},@{@"teacher_privacy_agreement":@"教师隐私政策"},@{@"teacher_protect_agreement":@"儿童隐私保护政策"},@{@"teacher_abstract":@"教师隐私政策摘要"},@{@"teacher_user_inventory":@"教师个人信息收集清单"},@{@"teacher_sdk_inventory":@"习教师第三方共享与SDK清单"},@{@"teacher_auth_inventory":@"习教师设备权限清单"}];
    }
    return _titleArray;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
